<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">

Ext.onReady(function(){
	
	Ext.tip.QuickTipManager.init();
	
	var itemsPerPage = 5; 
    //定义model 
    Ext.define('ReturnVisitVO', { 
        extend: 'Ext.data.Model', 
        // fields定义字段和数据类型 
        fields: ['id', 'secuitName', 'userName','RVisitContent','RVisitTime'] 
    });
    
    //定义数据集 
    var returnvisitstore = Ext.create('Ext.data.Store', {
        model: 'ReturnVisitVO', 
        pageSize: itemsPerPage,
        //使用ajax代理 
        proxy: { 
            type: 'ajax', 
            url: '../service/returnvisit_getbysecuit',
            //Reader 解码json数据 
            reader: { 
                type: 'json', 
                root: 'root', 
                total: 'total'
            }
        }
    });
    
	var secuitinfopanel=Ext.create('Ext.Panel', {
	    id:'secuitinfo-panel',
	    baseCls:'x-plain',
	    renderTo:'secuitinfo',
	    items:[{
	        xtype:'fieldset',
	        title: '招生信息',
	        collapsible: true,
	        defaultType: 'textfield',
	        layout: 'hbox',
	        items :[{
	        	xtype:'container',
		        layout: 'anchor',
		        collapsible: true,
		        defaultType: 'textfield',
		        items :[{
		            fieldLabel: '学生姓名:',
		            labelWidth:60,
		            width:200,
		            id: 'displayName',
		            margin:'10 10 0 0',
		        },{
		            fieldLabel: '学校:',
		            labelWidth:60,
		            width:200,
		            id: 'school',
		            margin:'10 10 0 0'
		        },{
		            fieldLabel: '到访时间:',
		            labelWidth:60,
		            width:200,
		            id: 'visitTime',
		            margin:'10 10 0 0'
		        }]
	        },{
	        	xtype:'container',
		        collapsible: true,
		        layout: 'anchor',
		        defaultType: 'textfield',
		        items :[{
		            fieldLabel: '年龄:',
		            labelWidth:60,
		            id: 'age',
		            width:200,
		            margin:'10 10 0 0',
		        },{
		            fieldLabel: 'E-mail:',
		            labelWidth:60,
		            id: 'EMail',
		            width:200,
		            margin:'10 10 0 0'
		        },{
		            fieldLabel: '联系电话:',
		            id: 'phone',
		            labelWidth:60,
		            width:200,
		            margin:'10 10 0 0'
		        }]
	        }]
	    },Ext.create('Ext.grid.Panel', {
        	store: returnvisitstore,
            columns: [ 
			{ 
			    text: '回访内容', width: 300, sortable: true, dataIndex: 'RVisitContent', editor: 'textfiled'
			},{ 
                text: '回访时间', width: 100, sortable: true, dataIndex: 'RVisitTime', editor: 'datefiled',renderer : Ext.util.Format.dateRenderer('Y/m/d'),
            },{ 
                text: '学生姓名', width: 80, dataIndex: 'secuitName', editor: 'textfield' 
            },{ 
                text: '老师', width: 80, dataIndex: 'userName', editor: 'textfield' 
            }],
            //分页 
            dockedItems: [{ 
                xtype: 'pagingtoolbar', 
                store: returnvisitstore,
                dock: 'bottom', 
                displayInfo: true 
                }]
        	})
	    ],
	    listeners:{
        	'render':function(){
        		returnvisitstore.load({
        			params: {
        		        id: Ext.getDom('secuitid').value
        		    },
        		});
        		Ext.Ajax.request({
        		    url: '../service/secuit_find',
        		    params: {
        		        id: Ext.getDom('secuitid').value
        		    },
        		    success: function(response, opts) {
        		        var obj = Ext.decode(response.responseText);
        		        Ext.getCmp('displayName').setValue(obj.secuit.displayName);
        		        Ext.getCmp('phone').setValue(obj.secuit.phont);
        		        Ext.getCmp('age').setValue(obj.secuit.age);
        		        Ext.getCmp('school').setValue(obj.secuit.school);
        		        Ext.getCmp('EMail').setValue(obj.secuit.EMail);
        		        var vtime=obj.secuit.visitTime.split('T')[0];
        		        Ext.getCmp('visitTime').setValue(vtime);
        		    },
        		});
        	}
        }
	});
});
</script>
</head>
<body>
<input type="hidden" id="secuitid" value="<s:property value='id'/>"/>
<div id="secuitinfo"></div>
</body>
</html>